package com.java.base.object;

import org.openjdk.jol.info.ClassLayout;

public class ObjectSizeTest {
    public static void main(String[] args) {
        test3();
//        System.out.println(Integer.MAX_VALUE - 5);
    }


    public static void test3() {
        System.out.println(ClassLayout.parseInstance(new byte[3]).toPrintable());
        System.out.println(ClassLayout.parseInstance(new Byte[3]).toPrintable());
        byte b = 0x00;
        System.out.println(ClassLayout.parseInstance(b).toPrintable());
        Byte by = 0x00;
        System.out.println(ClassLayout.parseInstance(by).toPrintable());

    }

    //boolean 2147483664
    //byte 2147483664 byte
    //Integer.MAX_VALUE - 5 = 2147483642
    public static void test2() {
        byte[] bs = new byte[Integer.MAX_VALUE - 2];
        System.out.println(bs.length);
        System.out.println(ClassLayout.parseInstance(bs).toPrintable());

    }

    /**
     * 关闭指针压缩
     * -XX:+PrintCommandLineFlags -XX:-UseCompressedClassPointers -XX:-UseCompressedOops
     */
    public static void test1() {
        System.out.println(ClassLayout.parseInstance(new Obj()).toPrintable());
    }

    public static class Obj {
//        int i;
        boolean b;
        Object obj;
    }


}
